package com.bjtu.ptsite.tracker.entity;

import jdk.jfr.BooleanFlag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 *
 * @author Zehao Wang, Junjie Zhang, Yutao Wei
 *
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class TrackerResponse {


    String failureReason;

    String warningMessage;

    Integer interval;

    Integer minInterval;

    String trackerId;

    Integer complete;
    Integer incomplete;

    /**
     * 下载次数
     * qbit可以看到
     */
    Integer downloaded;

    List<Map<String, Object>> peers;

    public static TrackerResponse build(Integer interval,
                                        Integer minInterval,
                                        Integer complete,
                                        Integer incomplete,
                                        List<Map<String, Object>> peers) {
        TrackerResponse response = new TrackerResponse();
        response.setInterval(interval);
        response.setMinInterval(minInterval);
        response.setComplete(complete);
        response.setIncomplete(incomplete);
        response.setPeers(peers);

        return response;
    }

    public Map<String, Object> toResultMap() {
        return Map.of(
                "interval", interval,
                "min interval", minInterval,
                "complete", complete,
                "incomplete", incomplete,
                "downloaded", 60,
                "downloaders", 70,
                "peers", peers
        );
    }
}